package com.test.designPattern.behaviorType.interpreterPattern;

/**
 * 终结符表达式,对乘法进行解释
 *
 * @author wangjie
 * @version V1.0
 * @date 2020/4/9
 */
public class MultiInterpreter implements Interpreter {
    private Interpreter firstExpression, secondExpression;
    public MultiInterpreter(Interpreter firstExpression, Interpreter secondExpression) {
        this.firstExpression = firstExpression;
        this.secondExpression = secondExpression;
    }
    @Override
    public double interpret() {
        return this.firstExpression.interpret() * this.secondExpression.interpret();
    }

    @Override
    public String toString() {
        return "*";
    }
}

